package cn.huyanbing.visual.spring.research.registrar;

import cn.huyanbing.visual.spring.research.registrar.config.AppConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @BelongProject middleware
 * @BelongPackage cn.huyanbing.visual.spring.research.registrar
 * @Description  测试
 * @ClassName RegistrarTest
 * @Author huyangbing
 * @Date 2024/11/3 22:22
 * @Version 1.0.0
 */
public class RegistrarTest {


    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        // 获取并调用 EnglishGreetingService
        GreetingService englishService = context.getBean("englishGreetingService", GreetingService.class);
        System.out.println(englishService.sayGreeting()); // 输出: Hello!

        // 获取并调用 SpanishGreetingService
        GreetingService spanishService = context.getBean("spanishGreetingService", GreetingService.class);
        System.out.println(spanishService.sayGreeting()); // 输出: ¡Hola!
    }
}
